<!DOCTYPE html>
<html>
<head>
  	<title>分布式任务调度平台</title>
  	<#import "../common/common.macro.ftl" as netCommon>
	<@netCommon.commonStyle />
	<!-- DataTables -->
  	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css">
  	<!-- daterangepicker -->
  	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.css">
</head>
<body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && cookieMap["adminlte_settings"]?exists && "off" == cookieMap["adminlte_settings"].value >sidebar-collapse</#if> ">
<div class="wrapper">
	<!-- header -->
	<@netCommon.commonHeader />
	<!-- left -->
	<@netCommon.commonLeft "env" />
	
	<!-- Content Wrapper. Contains page content -->
	<div class="content-wrapper">
		<!-- Content Header (Page header) -->
		<section class="content-header">
			<h1>任务管理</h1>
		</section>

		<!-- Main content -->
	    <section class="content">
			
			<div class="row">
				<div class="col-xs-12">
					<div class="box">
                        <div class="box-header">
                            <h3 class="box-title">任务列表</h3>&nbsp;&nbsp;
                            <button class="btn btn-info btn-xs pull-left2 add" >+新增任务</button>
                        </div>
			            <div class="box-body">
			              	<table id="joblog_list" class="table table-bordered table-striped display" width="100%" >
				                <thead>
					            	<tr>
                                        <th>任务名称</th>
                                        <th>任务类型</th>
                                        <th>任务状态</th>
                                        <th>调度表达式</th>
                                        <th>并发执行</th>
                                        <th>调度节点</th>
                                        <th>创建时间</th>
                                        <th>操作</th>
					                </tr>
				                </thead>
                                <tbody>
								<#if dataList?exists && dataList?size gt 0>
								<#list dataList as item>
									<tr>
                                        <td width="20%" >${item.taskName}</td>
                                        <td width="10%" >
                                            <#if item.taskType = 1>DUBBO<#else>HTTP</#if>
                                        </td>

                                        <td width="10%" >
                                            <#if item.status = 1>启用<#else>禁用</#if>
                                        </td>

                                        <td width="15%" >${item.cronExp}</td>
                                        <td width="10%" >
                                            <#if item.concurrentModel = 1>并发<#else>串行</#if>
                                        </td>
                                        <td width="10%" >
                                            <#if item.scheduleNode = ''>算法确定<#else> ${item.scheduleNode} </#if>
                                        </td>
                                        <td width="20%" >${item.createTimeText}</td>
										<td width="20%" >
                                            <button class="btn btn-warning btn-xs update"
                                                    dubboGroup="${item.dubboGroup}" dubboVersion="${item.dubboVersion}" httpUrl="${item.httpUrl}" httpMethod="${item.httpMethod}"
                                                    dubboService="${item.dubboService}" dubboMethod="${item.dubboMethod}" executorFailRetryCount="${item.executorFailRetryCount}"
                                                    executorTimeout="${item.executorTimeout}" ownerEmail="${item.ownerEmail}" owner="${item.owner}"
                                                    ownerPhone="${item.ownerPhone}" concurrentModel="${item.concurrentModel}"  executorRouteStrategy="${item.executorRouteStrategy}"
                                                    scheduleNode="${item.scheduleNode}" taskName="${item.taskName}" status="${item.status}"
                                                    cronExp="${item.cronExp}" taskType="${item.taskType}"  executorParam='${item.executorParam}'>编辑</button>
                                            <button class="btn btn-danger btn-xs remove" taskName="${item.taskName}" taskType="${item.taskType}" >删除</button>
                                            <button class="btn btn-danger btn-xs immediately_exec" taskName="${item.taskName}" taskType="${item.taskType}" >立即执行</button>
                                            <button class="btn btn-danger btn-xs alarmConfig" taskName="${item.taskName}" taskType="${item.taskType}" >告警配置</button>
										</td>
									</tr>
								</#list>
								</#if>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
	    </section>
	</div>

    <!-- 新增.模态框 -->
    <div class="modal fade" id="addModal" tabindex="-1" role="dialog"  aria-hidden="true">
        <div class="modal-dialog ">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" >新增任务</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal form" role="form" >
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务名称<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="taskName" placeholder="请输入任务名称" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务类型<font color="red">*</font></label>
                            <div class="col-sm-10">
                                <select class="form-control" name="taskType" id="taskType" >
                                    <option value="1">DUBBO</option>
                                    <option value="2">HTTP</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度表达式<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="cronExp" placeholder="请输入调度表达式" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">重试次数</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="retryNum" placeholder="请输入重试次数" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">超时时间(ms)</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="timeout" placeholder="请输入超时时间" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度开始时间</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="startTime" placeholder="请输入调度开始时间" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度结束时间</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="endTime" placeholder="请输入调度结束时间" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度节点</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="scheduleNode" placeholder="请输入调度节点" maxlength="500" ></div>
                        </div>


                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务描述</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="description" placeholder="请输入任务描述" maxlength="1000" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">执行器路由策略</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="executorRouteStrategy" placeholder="请输入执行器路由策略" maxlength="1000" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务状态<font color="red">*</font></label>
                            <div class="col-sm-10">
                                <div class="col-sm-10">
                                    <select class="form-control" name="status" id="status" >
                                        <option value="1">启用</option>
                                        <option value="2">禁用</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">允许并发执行<font color="red">*</font></label>
                            <div class="col-sm-10">
                                <div class="col-sm-10">
                                    <select class="form-control" name="concurrentModel" id="concurrentModel" >
                                        <option value="1">并发</option>
                                        <option value="0">串行</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务参数(json格式)</label>
                            <div class="col-sm-10">
                                <textarea class="textarea" name="executeParams" maxlength="2000" placeholder="请输入任务参数" style="width: 100%; height: 100px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">负责人<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="owner" placeholder="请输入负责人" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">负责人联系电话<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="ownerPhone" placeholder="请输入负责人联系电话" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">负责人电子邮箱<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="ownerEmail" placeholder="请输入负责人电子邮箱" maxlength="50" ></div>
                        </div>


                        <div class="form-group" id="div_dubbo_service">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo服务名<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboService" placeholder="请输入Dubbo服务名" maxlength="500" ></div>
                        </div>
                        <div class="form-group" id="div_dubbo_method">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo方法<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboMethod" placeholder="请输入Dubbo方法" maxlength="500" ></div>
                        </div>
                        <div class="form-group" id="div_dubbo_group">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo服务分组</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboGroup" placeholder="请输入Dubbo服务分组" maxlength="50" ></div>
                        </div>
                        <div class="form-group" id="div_dubbo_version">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo服务版本</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboVersion" placeholder="请输入Dubbo服务版本" maxlength="50" ></div>
                        </div>


                        <div class="form-group" id="div_http_addr">
                            <label for="lastname" class="col-sm-2 control-label">Http地址<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="httpUrl" placeholder="请输入Http地址" maxlength="500" ></div>
                        </div>
                        <div class="form-group" id="div_http_method">
                            <label for="lastname" class="col-sm-2 control-label">Http方法<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="httpMethod" placeholder="请输入Http方法" maxlength="50" ></div>
                        </div>

                        <hr>
                        <div class="form-group">
                            <div class="col-sm-offset-3 col-sm-6">
                                <button type="submit" class="btn btn-primary"  >保存</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

    <!-- 更新.模态框 -->
    <div class="modal fade" id="updateModal" tabindex="-1" role="dialog"  aria-hidden="true">
        <div class="modal-dialog ">
            <div class="modal-content">
                <div class="modal-header">
                    <h4 class="modal-title" >编辑任务</h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal form" role="form" >
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务名称<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="taskName" placeholder="请输入任务名称" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务类型<font color="red">*</font></label>
                            <div class="col-sm-10">
                                <select class="form-control" name="taskType" id="upt_taskType"  class="select" style="pointer-events: none;">
                                    <option value="1">DUBBO</option>
                                    <option value="2">HTTP</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度表达式<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="cronExp" placeholder="请输入调度表达式" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">重试次数</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="retryNum" placeholder="请输入重试次数" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">超时时间(ms)</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="timeout" placeholder="请输入超时时间" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度开始时间</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="startTime" placeholder="请输入调度开始时间" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度结束时间</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="endTime" placeholder="请输入调度结束时间" maxlength="50" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">调度节点</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="scheduleNode" placeholder="请输入调度节点" maxlength="50" ></div>
                        </div>


                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务描述</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="description" placeholder="请输入任务描述" maxlength="1000" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">执行器路由策略</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="executorRouteStrategy" placeholder="请输入执行器路由策略" maxlength="1000" ></div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务状态<font color="red">*</font></label>
                            <div class="col-sm-10">
                                <div class="col-sm-10">
                                    <select class="form-control" name="status" id="status" >
                                        <option value="1">启用</option>
                                        <option value="2">禁用</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">允许并发执行<font color="red">*</font></label>
                            <div class="col-sm-10">
                                <div class="col-sm-10">
                                    <select class="form-control" name="concurrentModel" id="concurrentModel" >
                                        <option value="1">并发</option>
                                        <option value="0">串行</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">任务参数(json格式)</label>
                            <div class="col-sm-10">
                                <textarea class="textarea" name="executeParams" id="" maxlength="2000" placeholder="请输入任务参数" style="width: 100%; height: 100px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">负责人<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="owner" placeholder="请输入负责人" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">负责人联系电话<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="ownerPhone" placeholder="请输入负责人联系电话" maxlength="50" ></div>
                        </div>
                        <div class="form-group">
                            <label for="lastname" class="col-sm-2 control-label">负责人电子邮箱<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="ownerEmail" placeholder="请输入负责人电子邮箱" maxlength="50" ></div>
                        </div>


                        <div class="form-group" id="div_upt_dubbo_service">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo服务名<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboService" placeholder="请输入Dubbo服务名" maxlength="500" ></div>
                        </div>
                        <div class="form-group" id="div_upt_dubbo_method">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo方法<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboMethod" placeholder="请输入Dubbo方法" maxlength="500" ></div>
                        </div>
                        <div class="form-group" id="div_upt_dubbo_group">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo服务分组</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboGroup" placeholder="请输入Dubbo服务分组" maxlength="50" ></div>
                        </div>
                        <div class="form-group" id="div_upt_dubbo_version">
                            <label for="lastname" class="col-sm-2 control-label">Dubbo服务版本</label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="dubboVersion" placeholder="请输入Dubbo服务版本" maxlength="50" ></div>
                        </div>


                        <div class="form-group" id="div_upt_http_addr">
                            <label for="lastname" class="col-sm-2 control-label">Http地址<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="httpUrl" placeholder="请输入Http地址" maxlength="500" ></div>
                        </div>
                        <div class="form-group" id="div_upt_http_method">
                            <label for="lastname" class="col-sm-2 control-label">Http方法<font color="red">*</font></label>
                            <div class="col-sm-10"><input type="text" class="form-control" name="httpMethod" placeholder="请输入Http方法" maxlength="50" ></div>
                        </div>
                        <hr>
                        <div class="form-group">
                            <div class="col-sm-offset-3 col-sm-6">
                                <button type="submit" class="btn btn-primary"  >保存</button>
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
	
	<!-- footer -->
	<@netCommon.commonFooter />
</div>

<@netCommon.commonScript />
<!-- DataTables -->
<script src="${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>
<script src="${request.contextPath}/static/js/task.manage.js"></script>
</body>
</html>
